package com.example.appointment.util;

import android.content.Context;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by Admin on 2016/7/6.
 */
public class AppJsonFileReader {
        public static String getJson(Context context, int fileName) {
            StringBuilder stringBuilder = new StringBuilder();
            try {
                InputStreamReader inputReader = new InputStreamReader(context.getResources().openRawResource(fileName));
                BufferedReader bufReader = new BufferedReader(inputReader);
                String line="";
                while((line = bufReader.readLine()) != null)
                    stringBuilder.append(line);
            } catch (Exception e) {
//                e.printStackTrace();
                Toast.makeText(context,"读取城市列表失败",Toast.LENGTH_SHORT).show();
            }
            return stringBuilder.toString();
        }
    }
